package org.example.springboot.common.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.example.springboot.common.domain.request.PageRequest;
import org.example.springboot.common.domain.response.PageResult;
import org.example.springboot.common.service.IBaseService;
import org.example.springboot.common.util.PageUtil;

public class BaseServiceImpl<M extends BaseMapper<T>, T> extends ServiceImpl<M, T> implements IBaseService<T> {

    @Override
    public <E extends PageRequest> Page<T> page(E pageRequest, Wrapper<T> queryWrapper) {
        return (Page<T>) page(PageUtil.parseRequest(pageRequest), queryWrapper);
    }

    @Override
    public <E extends PageRequest> PageResult<T> pageResult(E pageRequest, Wrapper<T> queryWrapper) {
        return PageUtil.parseResult(page(pageRequest, queryWrapper));
    }
}
